<template>
  <div class="Pastmedical">
    <van-cell-group>
      <van-cell title="是否药物过敏"
                :value="historyAllergy.drugName?'是':'否'"/>
      <van-cell title="过敏药物名称"
                :label="historyAllergy.drugName?historyAllergy.drugName:'无'"/>
      <van-cell title="是否有外伤史"
                :value="pastHistory.whether_trauma?'是':'否'"
                :label="pastHistory.whether_trauma?pastHistory.whether_trauma:'无'"/>
      <van-cell title="慢病史"
                :value="historyChroni.diseaseName?'是':'否'"/>
      <van-cell title="慢病史名称"
                :label="historyChroni.diseaseName?historyChroni.diseaseName:'无'"/>
      <van-cell title="窒息史"
                :value="pastHistory.whether_choking"/>
      <van-cell title="产伤"
                :value="pastHistory.whether_birth"/>
      <van-cell title="感染"
                :value="pastHistory.whether_infection"/>
      <van-cell title="出血"
                :value="pastHistory.whether_bleeding"/>
      <van-cell title="是否高热惊厥史"
                :value="pastHistory.whether_syncope"/>
    </van-cell-group>
  </div>
</template>

<script>
import {mapGetters} from "vuex";

export default {
  name: 'Pastmedical',
  mounted() {
    this.pastMedicalHistory();
    this.gethistoryChroni();
    this.getHistoryAllergy();
  },
  computed: {
    ...mapGetters(['userPhone'])
  },
  data() {
    return {
      pastHistory: '',//过往病史
      historyChroni: '',//慢病史
      historyAllergy: '',//过敏史
    }
  },
  methods: {
    //查询过敏史
    getHistoryAllergy() {
      this.$service.medicalHistoryService.getHistoryAllergy(this.userPhone).then(res => {
        this.historyAllergy = res.data.data[0];
        console.log('过敏史=' + JSON.stringify(this.historyAllergy));
      })
    },
    //查询过往病史后中的慢病史
    gethistoryChroni() {
      this.$service.medicalHistoryService.gethistoryChroni(this.userPhone).then(res => {
        this.historyChroni = res.data.data[0];
        console.log('慢病史=' + this.historyChroni);
      })
    },
    //查询过往病史
    pastMedicalHistory() {
      this.$service.medicalHistoryService.getDiseaseInfo(this.userPhone).then(res => {
        this.pastHistory = res.data.data;
        console.log('过往病史=' + JSON.stringify(this.pastHistory));
      })
    }
  }
}
</script>

<style scoped lang="less">

</style>
